package com.yufubao.api.controller.management.system;

import com.yufubao.framework.annotation.SystemLog;
import com.yufubao.framework.result.PageUtils;
import com.yufubao.framework.result.ResponseResult;
import com.yufubao.model.dto.management.sys.BeesUpdateStatusDto;
import com.yufubao.model.dto.management.sys.SysBeesDelDto;
import com.yufubao.model.dto.popularize.authorization.BeesInfoDto;
import com.yufubao.service.service.popularize.authorization.BeesInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2024/9/16 15:53
 */
@Api("推广人/小蜜蜂人员")
@RestController
@RequestMapping("/applet/management/sys/bees")
public class SysBeesController {


    @Autowired
    private BeesInfoService beesInfoService;

    /**
     * 分页列表
     */
    @RequestMapping(value = "/pageList", method = RequestMethod.POST)
    @ApiOperation(value = "推广人/小蜜蜂人员表列表")
    @SystemLog(info = "推广人/小蜜蜂人员表列表")
    public ResponseResult pageList(@RequestBody Map<String, Object> params) {
        PageUtils page = beesInfoService.queryPage(params);

        return ResponseResult.okResultPage("page", page);
    }


    /**
     * 新增小蜜蜂
     */
    @RequestMapping(value = "/saveInfo", method = RequestMethod.POST)
    @ApiOperation(value = "推广人/小蜜蜂人员表保存")
    @SystemLog(info = "推广人/小蜜蜂人员表保存")
    public ResponseResult saveInfo(@RequestBody BeesInfoDto dto) {
        beesInfoService.saveInfo(dto);

        return ResponseResult.ok();
    }

    /**
     * 修改状态
     */
    @RequestMapping(value = "/updateStatus", method = RequestMethod.PUT)
    @ApiOperation(value = "推广人/小蜜蜂人员表修改状态")
    @SystemLog(info = "推广人/小蜜蜂人员表修改状态")
    public ResponseResult updateStatus(@RequestBody  BeesUpdateStatusDto dto) {
        beesInfoService.updateStatus(dto.getBeesId(), dto.getStatus());

        return ResponseResult.ok();
    }


    /**
     * 单个删除/批量删除
     */
    @RequestMapping(value = "/deleteByIds", method = RequestMethod.POST)
    @ApiOperation(value = "单个删除/批量删除")
    @SystemLog(info = "单个删除/批量删除")
    public ResponseResult deleteByIds(@RequestBody List<SysBeesDelDto> dto) {
        beesInfoService.deleteByIds(dto);

        return ResponseResult.ok();
    }

}
